<template>
  <div>

    <el-form id="form" ref="form" :model="admin" :rules="rules" label-width="80px"
             label-position="right"  size="mini">
      <el-form-item label="姓名" prop="a_username" >
        <el-input v-model="admin.a_username"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="a_password">
        <el-input v-model="admin.a_password" type="password"></el-input>
      </el-form-item>

    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="save" size="mini">确定</el-button>
    </div>
  </div>
</template>

<script>
  export default{
    data() {
      return{
        admin:{
          a_username:'',
          a_password:''
        },
        rules:{
          a_username:[
            {
              required:true,
              message:'请输入姓名',
              trigger:'blur'
            },
            {
              min:3,
              max:50,
              message:'姓名的长度在3到50个字符之间',
              trigger:'blur'
            }
          ],
          a_password:[
            {
              required:true,
              message:'密码不能为空',
              trigger:'blur'
            },

          ],

        }
      }
    },
    methods:{
      //提交
      save(){
        this.$refs.form.validate((valid)=>{
          if(valid){

            this.$axios.post('AdminServlet/add?a_username='+ this.admin.a_username + '&a_password='+this.admin.a_password)
              .then(resp=>{
              })
          }else{
            console.log('验证未通过');
            return false
          }
        })
      }
    },

  }
</script>

<style scoped>

</style>
